package com.crm.model.pojo;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the permission database table.
 * 
 */
@Entity
@Table(name="permission")
@NamedQuery(name="Permission.findAll", query="SELECT p FROM Permission p")
public class Permission implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private String perid;

	private String perdescribe;

	private String pername;

	//bi-directional many-to-one association to Permission
	@ManyToOne
	@JoinColumn(name="pid")
	private Permission permission;

	//bi-directional many-to-one association to Permission
	@OneToMany(mappedBy="permission")
	private List<Permission> permissions;

	//bi-directional many-to-one association to Permissionallocation
	@OneToMany(mappedBy="permission")
	private List<Permissionallocation> permissionallocations;

	public Permission() {
	}

	public String getPerid() {
		return this.perid;
	}

	public void setPerid(String perid) {
		this.perid = perid;
	}

	public String getPerdescribe() {
		return this.perdescribe;
	}

	public void setPerdescribe(String perdescribe) {
		this.perdescribe = perdescribe;
	}

	public String getPername() {
		return this.pername;
	}

	public void setPername(String pername) {
		this.pername = pername;
	}

	public Permission getPermission() {
		return this.permission;
	}

	public void setPermission(Permission permission) {
		this.permission = permission;
	}

	public List<Permission> getPermissions() {
		return this.permissions;
	}

	public void setPermissions(List<Permission> permissions) {
		this.permissions = permissions;
	}

	public Permission addPermission(Permission permission) {
		getPermissions().add(permission);
		permission.setPermission(this);

		return permission;
	}

	public Permission removePermission(Permission permission) {
		getPermissions().remove(permission);
		permission.setPermission(null);

		return permission;
	}

	public List<Permissionallocation> getPermissionallocations() {
		return this.permissionallocations;
	}

	public void setPermissionallocations(List<Permissionallocation> permissionallocations) {
		this.permissionallocations = permissionallocations;
	}

	public Permissionallocation addPermissionallocation(Permissionallocation permissionallocation) {
		getPermissionallocations().add(permissionallocation);
		permissionallocation.setPermission(this);

		return permissionallocation;
	}

	public Permissionallocation removePermissionallocation(Permissionallocation permissionallocation) {
		getPermissionallocations().remove(permissionallocation);
		permissionallocation.setPermission(null);

		return permissionallocation;
	}

}